#include "cc.h"
#include "bsp_clk.h"
#include "bsp_led.h"
#include "bsp_delay.h"
#include "bsp_beep.h"
#include "bsp_gpio.h"
#include "bsp_key.h"
#include "bsp_int.h"
#include "bsp_exti.h"
#include "bsp_epittimer.h"
#include "bsp_keyfilter.h"


int main(void)
{

	// static uint8_t led_state = OFF;
	//static uint8_t beep_state = OFF;

	int_init();			/* 中断初始化 */
	imx6u_clkinit();	/* 时钟主频初始化，PLL1, PLL2, PLL3 */
	clk_init();			/* 使能所有外设时钟 */
	led_init();			/* led gpio 初始化 */
	beep_init();		/* beep gpio 初始化 */
	//key_init();			/* key gpio 初始化 */
	exti_init();		/* gpio外设中断初始化 */

	//epittimer_init(0, 0, 33000000);	/* EPIT分频frac=0 1分频，EPIT1时钟源66MHz，EPIT1->LR加载值计数器=33MHz，定时周期为500ms */
	epittimer_init(1, 0, 66000000/20);	/* EPIT分频frac=0 1分频，EPIT1时钟源66MHz，EPIT1->LR加载值计数器=33MHz，定时周期为1000/20=50ms */

	keyfilter_init();

	led_switch(LED_0, ON);


	beep_switch(ON);
	delay(200);
	beep_switch(OFF);
	delay(200);
	beep_switch(ON);
	delay(200);
	beep_switch(OFF);

    while(1){
		// led_state = !led_state;
		// led_switch(LED_0, led_state);
		//beep_state = !beep_state;
		//beep_switch(beep_state);

		delay(500);
    }

    return 0;
}